import { pick } from '../../utils/common';
import { useOperation } from '../../utils/operation';



export const roleParamsFilter = {
  *update ({
    roleGroupId, // 集团id
    // roleGroupName, // 集团名称
    roleName, // 角色名称
    rolePostId, // 岗位id
    // rolePostName, // 岗位名称
    roleType, // 角色类型
    roleId, // 角色id
  }, ctx) {
    const { call, set, put, select } = useOperation(ctx);
    const group = yield select(state => state.jituan);
    const position = yield select(state => state.position);
    const roleGroupName = pick(group.list, roleGroupId, 'id', 'group_name');
    const rolePostName = pick(position.list, rolePostId, 'id', 'name');

    return ({
      role_id: roleId,
      role_name: roleName,
      role_post: rolePostName,
      role_type: roleType,
      role_group_id: roleGroupId,
      role_group_name: roleGroupName
    });
  }, 
  add ({
    roleGroupId, // 集团id
    roleGroupName, // 集团名称
    roleName, // 角色名称
    rolePostId, // 岗位id
    rolePostName, // 岗位名称
    roleType, // 角色类型
  }) {
    return ({
      role_name: roleName,
      role_post: rolePostName,
      role_type: roleType,
      role_group_id: roleGroupId,
      role_group_name: roleGroupName,
    });
  }
}